package cyou.breathe.config;

import org.breathe.dynamic.thread.pool.core.thread.BreatheDtpExecutor;
import org.breathe.dynamic.thread.pool.core.thread.ThreadPoolBuilder;
import org.breathe.thread.pool.common.anno.SpringBreatheDtp;
import org.breathe.thread.pool.common.enums.QueueTypeEnum;
import org.breathe.thread.pool.common.enums.RejectedTypeEnum;
import org.springframework.context.annotation.Configuration;

/**
 * @author: breathe
 * @createTime: 2025-06-18
 */
@Configuration
public class BreatheThreadPoolConfiguration {
    @SpringBreatheDtp
    public BreatheDtpExecutor breatheDtpExecutor() {
        String threadPoolName = "select-seat-thread-pool-executor";;
        return ThreadPoolBuilder.newBuilder()
                .threadPoolName(threadPoolName)
                .threadFactory(threadPoolName)
                .workQueue(QueueTypeEnum.SYNCHRONOUS_QUEUE.getName(), 1000, false)
                .corePoolSize(24)
                .maximumPoolSize(36)
                .allowCoreThreadTimeOut(true)
                .keepAliveTime(1800000)
                .rejectedExecutionHandler(RejectedTypeEnum.CALLER_RUNS_POLICY.getName())
                .buildDynamic();

    }
}
